if (typeof getApp == 'function') {
	var app = getApp();
}
var api = require('./api.js');


/**
 * request 普通请求
 */

/**
 * request 普通请求
 */
function request(url, data = {}, dataType = '', method = "POST") {
	return new Promise(function (resolve, reject) {
		uni.request({
			url: api.path + url,
			data: data,
			method: method,
			header: {
				'content-type': 'application/x-www-form-urlencoded',
				'Accept-Language': 'zh-cn',
				'token': uni.getStorageSync('user').token
				// 'token': '3e9b4c36-bdf1-4417-8da6-08cb944e74ed'

			},
			success(res) {
				if (res.data.code == 1) {
					if (dataType) {
						resolve(res.data.data);
					} else {
						resolve(res.data.data);
					}
				} else if (res.data.code == 401) {
					toLogin();
				} else if (res.data.msg) {
					showToast(res.data.msg);
				}
			},
			fail(err) {
				showToast('加载失败，请检查网络');
			}
		})
	});
}

/**
 * 获取用户信息
 */
function getUserInfo(data = {}) {
	let that = this;
	return new Promise((resolve, reject) => {
		that.request(
			'/api/doctor/info', data, "POST"
		).then(res => {
			resolve(res);
		})
	});
}

function seeimg(list, index) {
	if (list[0].indexOf('http') == -1) {
		for (let i = 0; i < list.length; i++) {
			list[i] = api.img + list[i];
			if (i == list.length - 1) {
				console.log(list)
				uni.previewImage({
					current: index,
					urls: list
				})
			}
		}
	} else {
		console.log(list)
		uni.previewImage({
			current: index,
			urls: list
		})
	}
}
/**
 * 跳转到登录页面,并清空缓存
 */
function toLogin(e) {
	uni.hideLoading()
	uni.clearStorageSync();
	uni.reLaunch({
		url: "/pages/login/login"
	})
}
/**
 * 消息提示框
 */
function showToast(msg = '') {
	uni.showToast({
		title: msg,
		duration: 2000,
		icon: 'none'
	});
}
/**
 *  弹出提示信息结束后执行方法
 */
function showMsg(msg, callback) {
	uni.showToast({
		title: msg,
		icon: 'none',
		duration: 2000,
		success: function () {
			setTimeout(callback, 2000);
		}
	})
}
/**
 *  页面跳转
 */
function urlTo(e) {
	uni.navigateTo({
		url: e
	})
}
/**
 *手机掩码
 */
function phoneMask(phone) {
	if (phone) {
		return phone.substring(0, 3) + '****' + phone.substring(7);
	}
}
/**
 * 验证手机号
 */
function checkPhone(phone) {
	let zz = /^1[3456789]\d{9}$/;
	return zz.test(phone);
}
/**
 * 验证姓名
 */
function checkName(name) {
	let zz = /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/; //验证姓名正则
	return zz.test(name);
}
/*  
验证日期
*/
function checkDate(date) {
	let shengri_zz = /^\d{4}-\d{2}-\d{2}$/; //日期验证
	return shengri_zz.test(date);
}

/*  
格式化时间戳
*/
function timeChange(timestamp) {
	if (!timestamp) return "-";
	var date = new Date(timestamp * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
	var Y = date.getFullYear() + '-';
	var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
	var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
	var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
	var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
	var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
	return Y + M + D + h + m + s;
}
/* 
 判断是否微信浏览
 */
function isWeiXin() {
	var ua = window.navigator.userAgent.toLowerCase();
	if (ua.match(/MicroMessenger/i) == 'micromessenger') {
		return true;
	} else {
		return false;
	}
}
/* 
		验证邮箱
	 */
function checkEmail(value) {
	return /^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(value)
}
/* 
		身份证验证
	 */
function checkIDCard(idNum) {
	if (!idNum) {
		return false
	}
	// alert(idNum);
	var errors = new Array( // eslint-disable-line
		"alert('验证通过');",
		"alert('身份证号码位数不对');",
		"alert('身份证含有非法字符');",
		"alert('身份证号码校验错误');",
		"alert('身份证地区非法');"
	)
	// 身份号码位数及格式检验
	var re
	var len = idNum.length
	// 身份证位数检验
	if (len != 15 && len != 18) { // eslint-disable-line
		return false
	} else if (len == 15) { // eslint-disable-line
		re = new RegExp(/^(\d{6})()?(\d{2})(\d{2})(\d{2})(\d{3})$/)
	} else {
		re = new RegExp(/^(\d{6})()?(\d{4})(\d{2})(\d{2})(\d{3})([0-9xX])$/)
	}
	var area = {
		11: '北京',
		12: '天津',
		13: '河北',
		14: '山西',
		15: '内蒙古',
		21: '辽宁',
		22: '吉林',
		23: '黑龙江',
		31: '上海',
		32: '江苏',
		33: '浙江',
		34: '安徽',
		35: '福建',
		36: '江西',
		37: '山东',
		41: '河南',
		42: '湖北',
		43: '湖南',
		44: '广东',
		45: '广西',
		46: '海南',
		50: '重庆',
		51: '四川',
		52: '贵州',
		53: '云南',
		54: '西藏',
		61: '陕西',
		62: '甘肃',
		63: '青海',
		64: '宁夏',
		65: '新疆',
		71: '台湾',
		81: '香港',
		82: '澳门',
		91: '国外'
	}
	var idcard_array = new Array() // eslint-disable-line
	idcard_array = idNum.split('') // eslint-disable-line
	// 地区检验
	if (area[parseInt(idNum.substr(0, 2))] == null) {
		return false
	}
	// 出生日期正确性检验
	var a = idNum.match(re)
	if (a != null) { // eslint-disable-line
		var flag
		var DD
		if (len == 15) { // eslint-disable-line
			DD = new Date('19' + a[3] + '/' + a[4] + '/' + a[5])
			flag = DD.getYear() == a[3] && (DD.getMonth() + 1) == a[4] && DD.getDate() == a[5] // eslint-disable-line
		} else if (len == 18) { // eslint-disable-line
			DD = new Date(a[3] + '/' + a[4] + '/' + a[5])
			flag = DD.getFullYear() == a[3] && (DD.getMonth() + 1) == a[4] && DD.getDate() == a[
				5] // eslint-disable-line
		}
		if (!flag) {
			// return false;
			return false
		}
		// 检验校验位
		if (len == 18) { // eslint-disable-line
			var S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7 +
				(parseInt(idcard_array[1]) +
					parseInt(idcard_array[11])) * 9 +
				(parseInt(idcard_array[2]) +
					parseInt(idcard_array[12])) * 10 +
				(parseInt(idcard_array[3]) +
					parseInt(idcard_array[13])) * 5 +
				(parseInt(idcard_array[4]) +
					parseInt(idcard_array[14])) * 8 +
				(parseInt(idcard_array[5]) +
					parseInt(idcard_array[15])) * 4 +
				(parseInt(idcard_array[6]) +
					parseInt(idcard_array[16])) * 2 +
				parseInt(idcard_array[7]) * 1 +
				parseInt(idcard_array[8]) * 6 +
				parseInt(idcard_array[9]) * 3
			var Y = S % 11
			var M = 'F'
			var JYM = '10X98765432'
			M = JYM.substr(Y, 1) // 判断校验位
			// 检测ID的校验位
			if (M == idcard_array[17]) { // eslint-disable-line
				return true
				// return "";
			} else {
				// return false;
				return false
			}
		}
	} else {
		// return false;
		return false
	}
	return true
}
/* 
 APP检查更新
 */
function getVersion(e) {
	let _this = this;
	_this.request('', {
		type: api.appType
	}, 'POST').then(res => {
		if (1 == 1) {
			uni.showModal({
				title: '更新提示',
				content: '为了您的正常使用请您更新最新版本',
				showCancel: false,
				confirmText: '立即更新',
				success: function (gdx) {
					if (gdx.confirm) {
						console.log(res.data.url)
						plus.runtime.openURL(res.data.url);
					}
				}
			});
		}
		if (e == 1) {
			showToast('您已是最新版本');
		}
	})
}
/* 
 微信,支付宝 app支付调取
 */
function appPay(type, data) {
	let payType;
	if (type == 0) {
		payType = 'wxpay';
	} else if (type == 1) {
		payType = 'alipay'
	}
	return new Promise(function (resolve, reject) {
		uni.requestPayment({
			provider: payType,
			orderInfo: data,
			success(res) {
				console.log(res)
				showToast('支付成功');
				resolve();
			},
			fail(err) {
				console.log(err)
				showToast('支付失败');
			}
		})
	});
}
/* 
 微信小程序支付
 */
function wxPay(data) {
	return new Promise(function (resolve, reject) {
		uni.requestPayment({
			provider: 'wxpay',
			timeStamp: data.timeStamp,
			nonceStr: data.nonceStr,
			package: data.package,
			signType: data.signType,
			paySign: data.paySign,
			success: function (res) {
				console.log('success:' + JSON.stringify(res));
				showToast('支付成功');
				resolve();
			},
			fail: function (err) {
				console.log('fail:' + JSON.stringify(err));
				showToast('支付失败');
			}
		});
	});
}
/* 
 微信小程序版本更新
 */
function wxUpdate() {
	if (wx.canIUse('getUpdateManager')) {
		const updateManager = wx.getUpdateManager()
		updateManager.onCheckForUpdate(function (res) {
			console.log(res)
			// 请求完新版本信息的回调
			if (res.hasUpdate) {
				updateManager.onUpdateReady(function () {
					wx.showModal({
						title: '更新提示',
						content: '新版本已经准备好，是否重启应用？',
						success: function (res) {
							if (res.confirm) {
								// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
								updateManager.applyUpdate()
							}
						}
					})
				})
				updateManager.onUpdateFailed(function () {
					// 新的版本下载失败
					wx.showModal({
						title: '已经有新版本了哟~',
						content: '新版本已经上线啦~，请您删除当前小程序，重新搜索打开哟~',
					})
				})
			}
		})
	} else {
		// 如果希望用户在最新版本的客户端上体验您的小程序，可以这样子提示
		wx.showModal({
			title: '提示',
			content: '当前微信版本过低，无法使用该功能，请升级到最新微信版本后重试。'
		})
	}
}
/* 
 预览图片
 e:图片地址 可单张字符串或数组
 index:图片索引
 item:多数据数组情况下传 图片字段名
 */
function lookImg(e, index = 0, item) {
	let url;
	if (Array.isArray(e)) {
		url = e;
	} else {
		url = [e];
	}
	let urls = [];
	if (item) {
		url.map(i => {
			urls.push(i[item]);
		})
		url = urls;
	}
	uni.previewImage({
		urls: url,
		current: index
	})
}
/* 
 腾讯逆解析 传经纬度获取地址
 */
function getDistrict(latitude, longitude) {
	return new Promise((resolve, reject) => {
		// let keys = 'VCIBZ-WKSCX-DY74A-TCM3S-GLX7S-IABIU'//测试key
		let keys = 'Z2WBZ-7BB33-PSF3E-32VEW-SZMGO-6UBKK'
		wx.request({
			url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${latitude},${longitude}&key=${keys}`,
			header: {
				'Content-Type': 'application/json'
			},
			success: function (res) {
				console.log(res)
				resolve(res.data.result)
			}
		})
	})
}
/* 
 上传文件uploadFile
 */
function uploadFile(img) {
	uni.showLoading({
		title: '上传中'
	});
	let _this = this;
	const token = uni.getStorageSync('user').token;
	return new Promise(function (resolve, reject) {
		uni.uploadFile({
			url: api.path + '/api/common/upload',
			filePath: img,
			name: 'file',
			formData: {
				token: token
			},
			success: (uploadFileRes) => {
				console.log(uploadFileRes)
				let up = JSON.parse(uploadFileRes.data);
				if (up.code == 1) {
					resolve(up.data);
					uni.hideLoading();
				} else {
					_this.showToast(up.msg);
				}
			}
		});
	});
}
/* 
获取当前之后第几天的日期
 */
function getLaterDay(day) {
	var today = new Date();
	var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
	today.setTime(targetday_milliseconds); //注意，这行是关键代码
	var tYear = today.getFullYear();
	var tMonth = today.getMonth();
	var tDate = today.getDate();
	tMonth = doHandleMonth(tMonth + 1);
	tDate = doHandleMonth(tDate);
	return tYear + '-' + tMonth + "-" + tDate;

	function doHandleMonth(month) {
		var m = month;
		if (month.toString().length == 1) {
			m = '0' + month;
		}
		return m;
	}
}
/* 
格式化秒时间戳 为00:00:00格式 
 */
function secChange(time) {
	let h = parseInt(time / 3600);
	let min = parseInt((time - h * 3600) / 60);
	let s = parseInt(time - h * 3600 - min * 60);
	h = (h < 9 ? '0' : '') + h;
	min = (min < 9 ? '0' : '') + min;
	s = (s < 9 ? '0' : '') + s;
	return h + ':' + min + ':' + s;
}
/* 
 返回上级页面 time延迟执行的时间
 */
function backTo(e = 1, time = 0) {
	setTimeout(function () {
		uni.navigateBack({
			delta: e
		})
	}, time);
}
/* 
 从本地选择图片
 */
function addImg(num = 1, type) {
	let sourceType;
	if (type == 1) {
		sourceType = ['album'];
	} else if (type == 2) {
		sourceType = ['camera'];
	} else {
		sourceType = ['album', 'camera'];
	}
	return new Promise((resolve, reject) => {
		uni.chooseImage({
			count: num, //默认9
			sourceType: sourceType, //从相册选择
			success: function (res) {
				if (num == 1) {
					resolve(res.tempFilePaths[0]);
				} else {
					resolve(res.tempFilePaths);
				}
			}
		});
	})
}
/* 
 从本地选择视频
 */
function addVideo() {
	return new Promise((resolve, reject) => {
		uni.chooseVideo({
			success: function (res) {
				resolve(res.tempFilePath);
			}
		});
	})
}
/* 
 计算现在距未来某个节点的时间（倒计时）
 type:1时startTime为日期格式  2时startTime为秒级时间戳格式
 */
function getLiveTimeCount(startTime, type = 1) {
	if (type == 1) {
		let transedPreTime = startTime.replace(/-/g, '/'); //这里转化时间格式为以/分隔形式
		let preTime = new Date(transedPreTime).getTime();
	} else {
		let preTime = new Date(startTime * 1000).getTime();
	}
	let nowTime = new Date().getTime();
	let obj = null;
	if (preTime - nowTime > 0) {
		let time = (preTime - nowTime) / 1000;
		let day = parseInt(time / (60 * 60 * 24));
		let hou = parseInt(time % (60 * 60 * 24) / 3600);
		let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
		let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
		obj = {
			day: day < 10 ? '0' + day : day,
			hou: hou < 10 ? '0' + hou : hou,
			min: min < 10 ? '0' + min : min,
			sec: sec < 10 ? '0' + sec : sec
		};
	}
	return obj; //倒计时计算后的时间  {日：时：分：秒}
}
/* 
 复制文本到剪切板
 */
function copy(e) {
	uni.setClipboardData({
		data: e,
		success: function () { }
	});
}
/* 
 拨打电话
 */
function dial(e) {
	uni.makePhoneCall({
		phoneNumber: e
	});
}
/* 
截取h5地址的某一参数值 
 */
function GetQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	var r = window.location.search.substr(1).match(reg);
	if (r != null) return (decodeURIComponent(r[2]));
	return null;
}

/**
 * h5 跳转地图导航跳转地图app
 * 根据地图类型、位置获取不同的地图页面跳转链接
 * @param {*} mapType 地图类型
 * @param {*} location 经纬度 lat:纬度 lng:经度
 * @param {*} address 详细地址
 */
function getMapApp(mapType, lat, lng, address) {
	let url = '';
	switch (mapType) {
		case '腾讯地图':
			url = 'https://apis.map.qq.com/uri/v1/marker?marker=coord:' + lat + ',' + lng + ';addr:' +
				address + ';title:' + address + '&referer=keyfree';
			break;
		case '高德地图':
			url = 'https://uri.amap.com/marker?position=' + lng + ',' + lat + '&name=' + address +
				'&callnative=1';
			break;
		case '百度地图':
			url = 'http://api.map.baidu.com/marker?location=' + lat + ',' + lng + '&title=' + address +
				'&content=' +
				address + '&output=html&src=webapp.reformer.appname&coord_type=gcj02';
			break;
		default:
			break;
	}
	window.location.href = url;
}
/**
 * 国家和代码
 * @returns 国家和代码数组
 */
function getCountryCode() {
	return [
		{
			"prefix": "1",
			"en": "USA",
			"cn": "美国",
			"id": 1
		},
		{
			"prefix": "1",
			"en": "PuertoRico",
			"cn": "波多黎各",
			"id": 2
		},
		{
			"prefix": "1",
			"en": "Canada",
			"cn": "加拿大",
			"id": 3
		},
		{
			"prefix": "7",
			"en": "Russia",
			"cn": "俄罗斯",
			"id": 4
		},
		{
			"prefix": "7",
			"en": "Kazeakhstan",
			"cn": "哈萨克斯坦",
			"id": 5
		},
		{
			"prefix": "20",
			"en": "Egypt",
			"cn": "埃及",
			"id": 6
		},
		{
			"prefix": "27",
			"en": "South Africa",
			"cn": "南非",
			"id": 7
		},
		{
			"prefix": "30",
			"en": "Greece",
			"cn": "希腊",
			"id": 8
		},
		{
			"prefix": "31",
			"en": "Netherlands",
			"cn": "荷兰",
			"id": 9
		},
		{
			"prefix": "32",
			"en": "Belgium",
			"cn": "比利时",
			"id": 10
		},
		{
			"prefix": "33",
			"en": "France",
			"cn": "法国",
			"id": 11
		},
		{
			"prefix": "34",
			"en": "Spain",
			"cn": "西班牙",
			"id": 12
		},
		{
			"prefix": "36",
			"en": "Hungary",
			"cn": "匈牙利",
			"id": 13
		},
		{
			"prefix": "40",
			"en": "Romania",
			"cn": "罗马尼亚",
			"id": 14
		},
		{
			"prefix": "41",
			"en": "Switzerland",
			"cn": "瑞士",
			"id": 15
		},
		{
			"prefix": "43",
			"en": "Austria",
			"cn": "奥地利",
			"id": 16
		},
		{
			"prefix": "44",
			"en": "United Kingdom",
			"cn": "英国",
			"id": 17
		},
		{
			"prefix": "44",
			"en": "Jersey",
			"cn": "泽西岛",
			"id": 18
		},
		{
			"prefix": "44",
			"en": "Isle of Man",
			"cn": "马恩岛",
			"id": 19
		},
		{
			"prefix": "44",
			"en": "Guernsey",
			"cn": "根西",
			"id": 20
		},
		{
			"prefix": "45",
			"en": "Denmark",
			"cn": "丹麦",
			"id": 21
		},
		{
			"prefix": "46",
			"en": "Sweden",
			"cn": "瑞典",
			"id": 22
		},
		{
			"prefix": "47",
			"en": "Norway",
			"cn": "挪威",
			"id": 23
		},
		{
			"prefix": "48",
			"en": "Poland",
			"cn": "波兰",
			"id": 24
		},
		{
			"prefix": "51",
			"en": "Peru",
			"cn": "秘鲁",
			"id": 25
		},
		{
			"prefix": "52",
			"en": "Mexico",
			"cn": "墨西哥",
			"id": 26
		},
		{
			"prefix": "53",
			"en": "Cuba",
			"cn": "古巴",
			"id": 27
		},
		{
			"prefix": "54",
			"en": "Argentina",
			"cn": "阿根廷",
			"id": 28
		},
		{
			"prefix": "55",
			"en": "Brazill",
			"cn": "巴西",
			"id": 29
		},
		{
			"prefix": "56",
			"en": "Chile",
			"cn": "智利",
			"id": 30
		},
		{
			"prefix": "57",
			"en": "Colombia",
			"cn": "哥伦比亚",
			"id": 31
		},
		{
			"prefix": "58",
			"en": "Venezuela",
			"cn": "委内瑞拉",
			"id": 32
		},
		{
			"prefix": "60",
			"en": "Malaysia",
			"cn": "马来西亚",
			"id": 33
		},
		{
			"prefix": "61",
			"en": "Australia",
			"cn": "澳大利亚",
			"id": 34
		},
		{
			"prefix": "62",
			"en": "Indonesia",
			"cn": "印度尼西亚",
			"id": 35
		},
		{
			"prefix": "63",
			"en": "Philippines",
			"cn": "菲律宾",
			"id": 36
		},
		{
			"prefix": "64",
			"en": "NewZealand",
			"cn": "新西兰",
			"id": 37
		},
		{
			"prefix": "65",
			"en": "Singapore",
			"cn": "新加坡",
			"id": 38
		},
		{
			"prefix": "66",
			"en": "Thailand",
			"cn": "泰国",
			"id": 39
		},
		{
			"prefix": "81",
			"en": "Japan",
			"cn": "日本",
			"id": 40
		},
		{
			"prefix": "82",
			"en": "Korea",
			"cn": "韩国",
			"id": 41
		},
		{
			"prefix": "84",
			"en": "Vietnam",
			"cn": "越南",
			"id": 42
		},
		{
			"prefix": "86",
			"en": "China",
			"cn": "中国",
			"id": 43
		},
		{
			"prefix": "90",
			"en": "Turkey",
			"cn": "土耳其",
			"id": 44
		},
		{
			"prefix": "91",
			"en": "Indea",
			"cn": "印度",
			"id": 45
		},
		{
			"prefix": "92",
			"en": "Pakistan",
			"cn": "巴基斯坦",
			"id": 46
		},
		{
			"prefix": "93",
			"en": "Italy",
			"cn": "意大利",
			"id": 47
		},
		{
			"prefix": "93",
			"en": "Afghanistan",
			"cn": "阿富汗",
			"id": 48
		},
		{
			"prefix": "94",
			"en": "SriLanka",
			"cn": "斯里兰卡",
			"id": 49
		},
		{
			"prefix": "94",
			"en": "Germany",
			"cn": "德国",
			"id": 50
		},
		{
			"prefix": "95",
			"en": "Myanmar",
			"cn": "缅甸",
			"id": 51
		},
		{
			"prefix": "98",
			"en": "Iran",
			"cn": "伊朗",
			"id": 52
		},
		{
			"prefix": "212",
			"en": "Morocco",
			"cn": "摩洛哥",
			"id": 53
		},
		{
			"prefix": "213",
			"en": "Algera",
			"cn": "阿尔格拉",
			"id": 54
		},
		{
			"prefix": "216",
			"en": "Tunisia",
			"cn": "突尼斯",
			"id": 55
		},
		{
			"prefix": "218",
			"en": "Libya",
			"cn": "利比亚",
			"id": 56
		},
		{
			"prefix": "220",
			"en": "Gambia",
			"cn": "冈比亚",
			"id": 57
		},
		{
			"prefix": "221",
			"en": "Senegal",
			"cn": "塞内加尔",
			"id": 58
		},
		{
			"prefix": "222",
			"en": "Mauritania",
			"cn": "毛里塔尼亚",
			"id": 59
		},
		{
			"prefix": "223",
			"en": "Mali",
			"cn": "马里",
			"id": 60
		},
		{
			"prefix": "224",
			"en": "Guinea",
			"cn": "几内亚",
			"id": 61
		},
		{
			"prefix": "225",
			"en": "Cote divoire",
			"cn": "科特迪沃",
			"id": 62
		},
		{
			"prefix": "226",
			"en": "Burkina Faso",
			"cn": "布基纳法索",
			"id": 63
		},
		{
			"prefix": "227",
			"en": "Niger",
			"cn": "尼日尔",
			"id": 64
		},
		{
			"prefix": "228",
			"en": "Togo",
			"cn": "多哥",
			"id": 65
		},
		{
			"prefix": "229",
			"en": "Benin",
			"cn": "贝宁",
			"id": 66
		},
		{
			"prefix": "230",
			"en": "Mauritius",
			"cn": "毛里求斯",
			"id": 67
		},
		{
			"prefix": "231",
			"en": "Liberia",
			"cn": "利比里亚",
			"id": 68
		},
		{
			"prefix": "232",
			"en": "Sierra Leone",
			"cn": "塞拉利昂",
			"id": 69
		},
		{
			"prefix": "233",
			"en": "Ghana",
			"cn": "加纳",
			"id": 70
		},
		{
			"prefix": "234",
			"en": "Nigeria",
			"cn": "尼日利亚",
			"id": 71
		},
		{
			"prefix": "235",
			"en": "Chad",
			"cn": "乍得",
			"id": 72
		},
		{
			"prefix": "236",
			"en": "Central African Republic",
			"cn": "中非共和国",
			"id": 73
		},
		{
			"prefix": "237",
			"en": "Cameroon",
			"cn": "喀麦隆",
			"id": 74
		},
		{
			"prefix": "238",
			"en": "Cape Verde",
			"cn": "佛得角",
			"id": 75
		},
		{
			"prefix": "239",
			"en": "Sao Tome and Principe",
			"cn": "圣多美和普林西比",
			"id": 76
		},
		{
			"prefix": "240",
			"en": "Guinea",
			"cn": "几内亚",
			"id": 77
		},
		{
			"prefix": "241",
			"en": "Gabon",
			"cn": "加蓬",
			"id": 78
		},
		{
			"prefix": "242",
			"en": "Republic of the Congo",
			"cn": "刚果共和国",
			"id": 79
		},
		{
			"prefix": "243",
			"en": "Democratic Republic of the Congo",
			"cn": "刚果民主共和国",
			"id": 80
		},
		{
			"prefix": "244",
			"en": "Angola",
			"cn": "安哥拉",
			"id": 81
		},
		{
			"prefix": "247",
			"en": "Ascension",
			"cn": "阿森松岛",
			"id": 82
		},
		{
			"prefix": "248",
			"en": "Seychelles",
			"cn": "塞舌尔",
			"id": 83
		},
		{
			"prefix": "249",
			"en": "Sudan",
			"cn": "苏丹",
			"id": 84
		},
		{
			"prefix": "250",
			"en": "Rwanda",
			"cn": "卢旺达",
			"id": 85
		},
		{
			"prefix": "251",
			"en": "Ethiopia",
			"cn": "埃塞俄比亚",
			"id": 86
		},
		{
			"prefix": "253",
			"en": "Djibouti",
			"cn": "吉布提",
			"id": 87
		},
		{
			"prefix": "254",
			"en": "Kenya",
			"cn": "肯尼亚",
			"id": 88
		},
		{
			"prefix": "255",
			"en": "Tanzania",
			"cn": "坦桑尼亚",
			"id": 89
		},
		{
			"prefix": "256",
			"en": "Uganda",
			"cn": "乌干达",
			"id": 90
		},
		{
			"prefix": "257",
			"en": "Burundi",
			"cn": "布隆迪",
			"id": 91
		},
		{
			"prefix": "258",
			"en": "Mozambique",
			"cn": "莫桑比克",
			"id": 92
		},
		{
			"prefix": "260",
			"en": "Zambia",
			"cn": "赞比亚",
			"id": 93
		},
		{
			"prefix": "261",
			"en": "Madagascar",
			"cn": "马达加斯加",
			"id": 94
		},
		{
			"prefix": "262",
			"en": "Reunion",
			"cn": "留尼汪",
			"id": 95
		},
		{
			"prefix": "262",
			"en": "Mayotte",
			"cn": "马约特",
			"id": 96
		},
		{
			"prefix": "263",
			"en": "Zimbabwe",
			"cn": "津巴布韦",
			"id": 97
		},
		{
			"prefix": "264",
			"en": "Namibia",
			"cn": "纳米比亚",
			"id": 98
		},
		{
			"prefix": "265",
			"en": "Malawi",
			"cn": "马拉维",
			"id": 99
		},
		{
			"prefix": "266",
			"en": "Lesotho",
			"cn": "莱索托",
			"id": 100
		},
		{
			"prefix": "267",
			"en": "Botwana",
			"cn": "博茨瓦纳",
			"id": 101
		},
		{
			"prefix": "268",
			"en": "Swaziland",
			"cn": "斯威士兰",
			"id": 102
		},
		{
			"prefix": "269",
			"en": "Comoros",
			"cn": "科摩罗",
			"id": 103
		},
		{
			"prefix": "297",
			"en": "Aruba",
			"cn": "阿鲁巴",
			"id": 104
		},
		{
			"prefix": "298",
			"en": "Faroe Islands",
			"cn": "法罗群岛",
			"id": 105
		},
		{
			"prefix": "299",
			"en": "Greenland",
			"cn": "格陵兰",
			"id": 106
		},
		{
			"prefix": "350",
			"en": "Gibraltar",
			"cn": "直布罗陀",
			"id": 107
		},
		{
			"prefix": "351",
			"en": "Portugal",
			"cn": "葡萄牙",
			"id": 108
		},
		{
			"prefix": "352",
			"en": "Luxembourg",
			"cn": "卢森堡",
			"id": 109
		},
		{
			"prefix": "353",
			"en": "Ireland",
			"cn": "爱尔兰",
			"id": 110
		},
		{
			"prefix": "354",
			"en": "Iceland",
			"cn": "冰岛",
			"id": 111
		},
		{
			"prefix": "355",
			"en": "Albania",
			"cn": "阿尔巴尼亚",
			"id": 112
		},
		{
			"prefix": "356",
			"en": "Malta",
			"cn": "马耳他",
			"id": 113
		},
		{
			"prefix": "357",
			"en": "Cyprus",
			"cn": "塞浦路斯",
			"id": 114
		},
		{
			"prefix": "358",
			"en": "Finland",
			"cn": "芬兰",
			"id": 115
		},
		{
			"prefix": "359",
			"en": "Bulgaria",
			"cn": "保加利亚",
			"id": 116
		},
		{
			"prefix": "370",
			"en": "Lithuania",
			"cn": "立陶宛",
			"id": 117
		},
		{
			"prefix": "371",
			"en": "Latvia",
			"cn": "拉脱维亚",
			"id": 118
		},
		{
			"prefix": "372",
			"en": "Estonia",
			"cn": "爱沙尼亚",
			"id": 119
		},
		{
			"prefix": "373",
			"en": "Moldova",
			"cn": "摩尔多瓦",
			"id": 120
		},
		{
			"prefix": "374",
			"en": "Armenia",
			"cn": "亚美尼亚",
			"id": 121
		},
		{
			"prefix": "375",
			"en": "Belarus",
			"cn": "白俄罗斯",
			"id": 122
		},
		{
			"prefix": "376",
			"en": "Andorra",
			"cn": "安道尔",
			"id": 123
		},
		{
			"prefix": "377",
			"en": "Monaco",
			"cn": "摩纳哥",
			"id": 124
		},
		{
			"prefix": "378",
			"en": "San Marino",
			"cn": "圣马力诺",
			"id": 125
		},
		{
			"prefix": "380",
			"en": "Ukraine",
			"cn": "乌克兰",
			"id": 126
		},
		{
			"prefix": "381",
			"en": "Serbia",
			"cn": "塞尔维亚",
			"id": 127
		},
		{
			"prefix": "382",
			"en": "Montenegro",
			"cn": "黑山",
			"id": 128
		},
		{
			"prefix": "383",
			"en": "Kosovo",
			"cn": "科索沃",
			"id": 129
		},
		{
			"prefix": "385",
			"en": "Croatia",
			"cn": "克罗地亚",
			"id": 130
		},
		{
			"prefix": "386",
			"en": "Slovenia",
			"cn": "斯洛文尼亚",
			"id": 131
		},
		{
			"prefix": "387",
			"en": "Bosnia and Herzegovina",
			"cn": "波斯尼亚和黑塞哥维那",
			"id": 132
		},
		{
			"prefix": "389",
			"en": "Macedonia",
			"cn": "马其顿",
			"id": 133
		},
		{
			"prefix": "420",
			"en": "Czech Republic",
			"cn": "捷克共和国",
			"id": 134
		},
		{
			"prefix": "421",
			"en": "Slovakia",
			"cn": "斯洛伐克",
			"id": 135
		},
		{
			"prefix": "423",
			"en": "Liechtenstein",
			"cn": "列支敦士登",
			"id": 136
		},
		{
			"prefix": "501",
			"en": "Belize",
			"cn": "伯利兹",
			"id": 137
		},
		{
			"prefix": "502",
			"en": "Guatemala",
			"cn": "危地马拉",
			"id": 138
		},
		{
			"prefix": "503",
			"en": "EISalvador",
			"cn": "艾萨尔瓦多",
			"id": 139
		},
		{
			"prefix": "504",
			"en": "Honduras",
			"cn": "洪都拉斯",
			"id": 140
		},
		{
			"prefix": "505",
			"en": "Nicaragua",
			"cn": "尼加拉瓜",
			"id": 141
		},
		{
			"prefix": "506",
			"en": "Costa Rica",
			"cn": "哥斯达黎加",
			"id": 142
		},
		{
			"prefix": "507",
			"en": "Panama",
			"cn": "巴拿马",
			"id": 143
		},
		{
			"prefix": "509",
			"en": "Haiti",
			"cn": "海地",
			"id": 144
		},
		{
			"prefix": "590",
			"en": "Guadeloupe",
			"cn": "瓜德罗普",
			"id": 145
		},
		{
			"prefix": "591",
			"en": "Bolivia",
			"cn": "玻利维亚",
			"id": 146
		},
		{
			"prefix": "592",
			"en": "Guyana",
			"cn": "圭亚那",
			"id": 147
		},
		{
			"prefix": "593",
			"en": "Ecuador",
			"cn": "厄瓜多尔",
			"id": 148
		},
		{
			"prefix": "594",
			"en": "French Guiana",
			"cn": "法属圭亚那",
			"id": 149
		},
		{
			"prefix": "595",
			"en": "Paraguay",
			"cn": "巴拉圭",
			"id": 150
		},
		{
			"prefix": "596",
			"en": "Martinique",
			"cn": "马提尼克",
			"id": 151
		},
		{
			"prefix": "597",
			"en": "Suriname",
			"cn": "苏里南",
			"id": 152
		},
		{
			"prefix": "598",
			"en": "Uruguay",
			"cn": "乌拉圭",
			"id": 153
		},
		{
			"prefix": "599",
			"en": "Netherlands Antillse",
			"cn": "荷属安的列斯",
			"id": 154
		},
		{
			"prefix": "670",
			"en": "Timor Leste",
			"cn": "东帝汶",
			"id": 155
		},
		{
			"prefix": "673",
			"en": "Brunei",
			"cn": "文莱",
			"id": 156
		},
		{
			"prefix": "675",
			"en": "Papua New Guinea",
			"cn": "巴布亚新几内亚",
			"id": 157
		},
		{
			"prefix": "676",
			"en": "Tonga",
			"cn": "汤加",
			"id": 158
		},
		{
			"prefix": "678",
			"en": "Vanuatu",
			"cn": "瓦努阿图",
			"id": 159
		},
		{
			"prefix": "679",
			"en": "Fiji",
			"cn": "斐济",
			"id": 160
		},
		{
			"prefix": "682",
			"en": "Cook Islands",
			"cn": "库克群岛",
			"id": 161
		},
		{
			"prefix": "684",
			"en": "Samoa Eastern",
			"cn": "萨摩亚东部",
			"id": 162
		},
		{
			"prefix": "685",
			"en": "Samoa Western",
			"cn": "萨摩亚西部",
			"id": 163
		},
		{
			"prefix": "687",
			"en": "New Caledonia",
			"cn": "新喀里多尼亚",
			"id": 164
		},
		{
			"prefix": "689",
			"en": "French Polynesia",
			"cn": "法属波利尼西亚",
			"id": 165
		},
		{
			"prefix": "852",
			"en": "Hong Kong",
			"cn": "香港",
			"id": 166
		},
		{
			"prefix": "853",
			"en": "Macao",
			"cn": "澳门",
			"id": 167
		},
		{
			"prefix": "855",
			"en": "Cambodia",
			"cn": "柬埔寨",
			"id": 168
		},
		{
			"prefix": "856",
			"en": "Laos",
			"cn": "老挝",
			"id": 169
		},
		{
			"prefix": "880",
			"en": "Bangladesh",
			"cn": "孟加拉国",
			"id": 170
		},
		{
			"prefix": "886",
			"en": "Taiwan",
			"cn": "台湾",
			"id": 171
		},
		{
			"prefix": "960",
			"en": "Maldives",
			"cn": "马尔代夫",
			"id": 172
		},
		{
			"prefix": "961",
			"en": "Lebanon",
			"cn": "黎巴嫩",
			"id": 173
		},
		{
			"prefix": "962",
			"en": "Jordan",
			"cn": "约旦",
			"id": 174
		},
		{
			"prefix": "963",
			"en": "Syria",
			"cn": "叙利亚",
			"id": 175
		},
		{
			"prefix": "964",
			"en": "Iraq",
			"cn": "伊拉克",
			"id": 176
		},
		{
			"prefix": "965",
			"en": "Kuwait",
			"cn": "科威特",
			"id": 177
		},
		{
			"prefix": "966",
			"en": "Saudi Arabia",
			"cn": "沙特阿拉伯",
			"id": 178
		},
		{
			"prefix": "967",
			"en": "Yemen",
			"cn": "也门",
			"id": 179
		},
		{
			"prefix": "968",
			"en": "Oman",
			"cn": "阿曼",
			"id": 180
		},
		{
			"prefix": "970",
			"en": "Palestinian",
			"cn": "巴勒斯坦",
			"id": 181
		},
		{
			"prefix": "971",
			"en": "United Arab Emirates",
			"cn": "阿拉伯联合酋长国",
			"id": 182
		},
		{
			"prefix": "972",
			"en": "Israel",
			"cn": "以色列",
			"id": 183
		},
		{
			"prefix": "973",
			"en": "Bahrain",
			"cn": "巴林",
			"id": 184
		},
		{
			"prefix": "974",
			"en": "Qotar",
			"cn": "卡塔尔",
			"id": 185
		},
		{
			"prefix": "975",
			"en": "Bhutan",
			"cn": "不丹",
			"id": 186
		},
		{
			"prefix": "976",
			"en": "Mongolia",
			"cn": "蒙古",
			"id": 187
		},
		{
			"prefix": "977",
			"en": "Nepal",
			"cn": "尼泊尔",
			"id": 188
		},
		{
			"prefix": "992",
			"en": "Tajikistan",
			"cn": "塔吉克斯坦",
			"id": 189
		},
		{
			"prefix": "993",
			"en": "Turkmenistan",
			"cn": "土库曼斯坦",
			"id": 190
		},
		{
			"prefix": "994",
			"en": "Azerbaijan",
			"cn": "阿塞拜疆",
			"id": 191
		},
		{
			"prefix": "995",
			"en": "Georgia",
			"cn": "格鲁吉亚",
			"id": 192
		},
		{
			"prefix": "996",
			"en": "Kyrgyzstan",
			"cn": "吉尔吉斯斯坦",
			"id": 193
		},
		{
			"prefix": "998",
			"en": "Uzbekistan",
			"cn": "乌兹别克斯坦",
			"id": 194
		},
		{
			"prefix": "1242",
			"en": "Bahamas",
			"cn": "巴哈马",
			"id": 195
		},
		{
			"prefix": "1246",
			"en": "Barbados",
			"cn": "巴巴多斯",
			"id": 196
		},
		{
			"prefix": "1264",
			"en": "Anguilla",
			"cn": "安圭拉",
			"id": 197
		},
		{
			"prefix": "1268",
			"en": "Antigua and Barbuda",
			"cn": "安提瓜和巴布达",
			"id": 198
		},
		{
			"prefix": "1340",
			"en": "Virgin Islands",
			"cn": "维尔京群岛",
			"id": 199
		},
		{
			"prefix": "1345",
			"en": "Cayman Islands",
			"cn": "开曼群岛",
			"id": 200
		},
		{
			"prefix": "1441",
			"en": "Bermuda",
			"cn": "百慕大",
			"id": 201
		},
		{
			"prefix": "1473",
			"en": "Grenada",
			"cn": "格林纳达",
			"id": 202
		},
		{
			"prefix": "1649",
			"en": "Turks and Caicos Islands",
			"cn": "特克斯和凯科斯群岛",
			"id": 203
		},
		{
			"prefix": "1664",
			"en": "Montserrat",
			"cn": "蒙特塞拉特",
			"id": 204
		},
		{
			"prefix": "1671",
			"en": "Guam",
			"cn": "关岛",
			"id": 205
		},
		{
			"prefix": "1758",
			"en": "St.Lucia",
			"cn": "圣卢西亚",
			"id": 206
		},
		{
			"prefix": "1767",
			"en": "Dominica",
			"cn": "多米尼加",
			"id": 207
		},
		{
			"prefix": "1784",
			"en": "St.Vincent",
			"cn": "圣文森特",
			"id": 208
		},
		{
			"prefix": "1809",
			"en": "Dominican Republic",
			"cn": "多米尼加共和国",
			"id": 209
		},
		{
			"prefix": "1868",
			"en": "Trinidad and Tobago",
			"cn": "特立尼达和多巴哥",
			"id": 210
		},
		{
			"prefix": "1869",
			"en": "St Kitts and Nevis",
			"cn": "圣基茨和尼维斯",
			"id": 211
		},
		{
			"prefix": "1876",
			"en": "Jamaica",
			"cn": "牙买加",
			"id": 212
		}
	];
}
/**
* 返回交易状态文字
* @param {String|Number} state 订单状态:1=待支付,2=待发货,3=待收货,4=待评论,5=售后订单,6=已完成,7=已取消
*/
function getOrderStatus(state) {
	var txt = "";
	switch (Number(state)) {
		case 1:
			txt = "待支付";
			break;
		case 2:
			txt = "待发货";
			break;
		case 3:
			txt = "待收货";
			break;
		case 4:
			txt = "待评论";
			break;
		case 5:
			txt = "售后订单";
			break;
		case 6:
			txt = "已完成";
			break;
		case 7:
			txt = "已取消";
			break;
		default:
			txt = "未知";
			break;
	}
	return txt;
}
/**
 * 深拷贝
 * @param {Object} obj 对象
 * @returns 深拷贝后的对象
 */
function deepClone(obj) {
	//判断拷贝的要进行深拷贝的是数组还是对象，是数组的话进行数组拷贝，对象的话进行对象拷贝
	var objClone = Array.isArray(obj) ? [] : {};
	//进行深拷贝的不能为空，并且是对象或者是
	if (obj && typeof obj === "object") {
		for (key in obj) {
			if (obj.hasOwnProperty(key)) {
				if (obj[key] && typeof obj[key] === "object") {
					objClone[key] = deepClone(obj[key]);
				} else {
					objClone[key] = obj[key];
				}
			}
		}
	}
	return objClone;
}
/**
 * 图片转换
 * @param {String} base64 图片
 * @returns Blob
 */
function base64ToBlob(base64) {
	var arr = base64.split(","),
		mime = arr[0].match(/:(.*?);/)[1],
		bstr = atob(arr[1]),
		n = bstr.length,
		u8arr = new Uint8Array(n);
	while (n--) {
		u8arr[n] = bstr.charCodeAt(n);
	}
	return new Blob([u8arr], {
		type: mime,
	});
}
module.exports = {
	request,
	toLogin,
	showToast,
	showMsg,
	checkPhone,
	checkName,
	checkDate,
	urlTo,
	phoneMask,
	getUserInfo,
	timeChange,
	isWeiXin,
	checkEmail,
	checkIDCard,
	getVersion,
	appPay,
	wxPay,
	wxUpdate,
	lookImg,
	getDistrict,
	uploadFile,
	getLaterDay,
	secChange,
	backTo,
	addImg,
	addVideo,
	getLiveTimeCount,
	copy,
	dial,
	GetQueryString,
	getMapApp,
	api,
	seeimg,
	getCountryCode,
	getOrderStatus,
	deepClone,
	base64ToBlob
}